package com.hjm.friend.controller.exam;


import com.hjm.common.core.controller.BaseController;
import com.hjm.common.core.domain.Result;
import com.hjm.common.core.domain.page.TableDataInfo;
import com.hjm.friend.domain.exam.dto.ExamQueryDTO;
import com.hjm.friend.domain.exam.dto.ExamRankQueryDTO;
import com.hjm.friend.service.exam.impl.ExamServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/exam")
public class ExamController extends BaseController {

    @Autowired
    ExamServiceImpl examService;

    @GetMapping("/semiLogin/list")
    // 允许游客访问
    public TableDataInfo list(ExamQueryDTO examQueryDTO){
        return getTableData(examService.list(examQueryDTO));
    }

    @GetMapping("/semiLogin/redis/list")
    // 允许游客访问
    public TableDataInfo redisList(ExamQueryDTO examQueryDTO){
        return examService.redisList(examQueryDTO);
    }

    @GetMapping("/rank/list")
    // 允许游客访问
    public TableDataInfo rankList(ExamRankQueryDTO examRankQueryDTO){
        return examService.rankList(examRankQueryDTO);
    }

    @GetMapping("/getFirstQuestion")
    public Result<String> getFirstQuestion(Long examId){
        return Result.ok(examService.getFirstQuestion(examId));
    }

    @GetMapping("/preQuestion")
    public Result<String> preQuestion(Long examId , Long questionId) {
        return Result.ok(examService.preQuestion(examId,questionId));
    }

    @GetMapping("/nextQuestion")
    public Result<String> nextQuestion(Long examId , Long questionId) {
        return Result.ok(examService.nextQuestion(examId,questionId));
    }
}
